{extend name="public:layout" /}
{block name="title"}
圈子申请列表
{/block}
{block name="head"}
<link rel="stylesheet" href="/public/plugins/dropload/dropload.css">
<style>
    .weui-navbar{position: relative;}
</style>
{/block}
{block name="body"}
<div class="mcm-head">
    <div class="head-left">
        <a href="javascript:history.back(-1)" class="link">
            <span class="iconfont icon-zuoyou1"></span>
        </a>
    </div>
    <div class="head-title">
        圈子申请列表
    </div>
</div>
<div style="height:50px;"></div>
<div class="circle-box">
    <ul class="circle-list" id="circle-list">
    </ul>
    <div id="page"></div>
</div>
{/block}
{block name="js"}
<script src="/public/plugins/dropload/dropload.min.js"></script>
<script src="/public/plugins/template/template.js"></script>
<script type="text/html" id="circle-tpl">
    {{ each data as value}}
    <li class="item">
        {{ if value.cm_state==0}}
        <a  class="link">正在<br>申请</a>
        {{ else if value.cm_state==1}}
        <a  href="{:url('Theme/index')}?circle_id={{ value.circle_id}}"  class="link">进入<br>圈子</a>
        {{ else}}
        <a  href="{:url('Public/circleApply')}?circle_id={{ value.circle_id}}"  class="link">申请<br>圈子</a>
        {{ /if}}
        <h2 class="info-tit">
            {{ value.circle_name}} <span class="iconfont icon-remen" style="color:red"></span>
        </h2>
        <p class="info-desc">
            <span class="tit"><a href="{:url('/circle/Public/circleShare')}?circle_id={{ value.circle_id}}">点击进入圈子介绍页面</a></span><br>
        </p>
    </li>
    {{ /each}}
</script>
<script>
    var parms = {
        status:1,
        circle_name: '',
        page: 0
    };
    // dropload
    var drop = $('#page').dropload({
        scrollArea : window,
        domDown: {
            domClass: 'dropload-down',
            domRefresh: '<div class="dropload-refresh">↑上拉加载更多</div>',
            domLoad: '<div class="dropload-load">○加载中...</div>',
            domNoData: '<div class="dropload-noData">到底了</div>'
        },
        loadDownFn: function (me) {
            parms.page++;
            // 拼接HTML
            var _=this;
            $.post('{:url("apply")}', parms, function (res) {
                if (parms.page >= res.last_page) {
                    if (res.last_page<=0){
                        _.domDown.domNoData= '<div class="dropload-noData">没有加入圈子</div>'
                    }
                    me.noData();
                    me.lock();
                }
                res.status=parms.status;
                var html = template('circle-tpl', res);
                $('#circle-list').append(html);
                me.resetload();
                /*当前只有一页，不显示到底了*/
                if(res.last_page==1){
                    $('.dropload-noData').hide();
                }
            });
        }
    });
    function setCircle(circle_name) {
        parms.circle_name=circle_name;
        $('#circle-list').empty();
        parms.page = 0;
        drop.noData(false);
        drop.unlock();
        drop.resetload();
    }
    function setStatus(status) {
        parms.status=status;
        $('#circle-list').empty();
        parms.page = 0;
        drop.noData(false);
        drop.unlock();
        drop.resetload();
    }
</script>
{/block}